package wqh.controller.api;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by devts on 2016/12/8.
 */
public class GlobalData {

    private static final Map<String,Object> map = new ConcurrentHashMap<String, Object>();

    public static synchronized void addData(String ip, Object data){
        map.put(ip,data);
    }

    public static synchronized void removeData(String ip){
        map.remove(ip);
    }

    public static synchronized List< Map<String, Object>> getMap() {
        List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
        if(map.size() == 0) return mapList;
        mapList.add(map);
        return mapList;
    }

    public static synchronized void clear(){
        map.clear();
    }

}
